home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-09-11 | 3.9 KB | 124 lines | [TEXT/CWIE] |
- // IAAnalysis.h
- // Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- #pragma once
- #ifndef IAAnalysis_h
- #define IAAnalysis_h
-
- #pragma import on
-
- #include "IACorpus.h"
-
- #pragma IA_BEGIN_EXPORTS
-
- class IATerm : public IAOrderedStorable {
- public:
- IATerm(const byte* d, uint32 l);
- virtual ~IATerm(); // frees data
-
- IAStorable* DeepCopy() const;
- IABlockSize StoreSize() const;
- void Store(IAOutputBlock* output) const;
- IAStorable* Restore(IAInputBlock* input) const;
-
- bool LessThan(const IAOrderedStorable* neighbor) const;
- bool Equal(const IAOrderedStorable* neighbor) const;
-
- // non-virtual implementations for use by performance-critical code
- // note: this means that LessThan & Equal mustn't be overridden by subclasses
- bool LessThanNonVirtual(const IAOrderedStorable* neighbor) const;
- bool EqualNonVirtual(const IAOrderedStorable* neighbor) const;
-
- byte* GetData() const {return data;}
- const uint32 GetDataLength() const {return dataLen;}
- private:
- IATerm(byte* d, uint32 l, bool makeCopy);
- byte* AllocData(uint32 l) const;
- IATerm(IATerm&); // don't define a copy constructor
- byte* data; // alloated with IAMallocArraySized
- const uint32 dataLen;
-
- };
-
- class IAToken : public IAObject {
- public:
- IAToken(IATerm* t, uint32 s, uint32 e)
- : term(t), startPos(s), endPos(e) {}
- IA_INLINE ~IAToken() IA_INLINE_DEF_BODY(delete term)
-
- IATerm* GetTerm() const {return term;}
- const uint32 GetStartPosition() const {return startPos;}
- const uint32 GetEndPosition() const {return endPos;}
-
- private:
- IAToken(IAToken&); // don't define a copy constructor
- // the unique type
- IATerm* term;
- // the byte position of the first character in the text corresponding to this token
- const uint32 startPos;
- // one greater than the position of the last character corresponding to this token
- const uint32 endPos;
-
- };
-
- class IATokenStream : public IAObject {
- public:
- IATokenStream() {};
- virtual ~IATokenStream() {};// no-op dtor def
- // Returns the next token in the stream, or NULL at end of stream.
- virtual IAToken* GetNextToken() = 0;
- // Copies into dest a span of bytes from the source text .
- // The span must start less than a buffer before the end of the last token read, and
- // it may not extend past the end of the last token read.
- // If it starts more than a buffer before, AnalysisSpanUnavailable is signalled.
- virtual void GetTextSpan(byte* dest, uint32 startPos, uint32 endPos) = 0;
- };
-
- IAExceptionCode AnalysisSpanUnavailable = 'VASU';
-
- class IATokenFilter : public IATokenStream {
- public:
- IATokenFilter(IATokenStream* s); // source = s;
- ~IATokenFilter(); // delete source;
- // GetText() on a filter delegates to its source by default.
- void GetTextSpan(byte* buffer, uint32 startPos, uint32 endPos) {
- source->GetTextSpan(buffer, startPos, endPos);
- }
- protected:
-
- IATokenStream* GetTokenStream() const {return source;}
- private:
- IATokenFilter(IATokenFilter& o); // don't define a copy constructor
- // The source of tokens to be filtered.
- IATokenStream* source;
-
- };
-
- class IAAnalysis : public IAObject {
- public:
- IAAnalysis(uint32 type); // : analysisType(type) {}
- IA_INLINE ~IAAnalysis() IA_INLINE_DEF()// no-op dtor def
-
-
-
- // Initializes persistent state, writing analysis paramters to storage.
- virtual void Initialize(IAStorage* storage, IABlockID block); // {}
- // Reads persistent state, checking that it’s consistent with current parameters.
- virtual void Open(IAStorage* storage, IABlockID block); // {}
-
- // Builds and returns a tokenizer.
- virtual IATokenStream* MakeTokenStream(IADocText* docText) = 0;
- // returns a prototype term, for bootstrapping sets of terms
- virtual IATerm* GetProtoTerm() = 0;
-
- const uint32 GetAnalysisType() const {return analysisType;}
-
- private:
- const uint32 analysisType;
- };
-
- #pragma IA_END_EXPORTS
-
- #pragma import reset
-
- #endif